clear,clc;
test;

function [] = test()    
load gas;
inter_esti([price1,price2],0.5);
end

% 获取一批正态分布样本（data）总体均值 u 的置信度为 a 的置信区间
% data可以为矩阵，则函数将对其逐列操作
function [u] = inter_esti(data,a)
[length,width] = size(data);
mu = mean(data)';
sig = std(data)';
u = [mu-sig/sqrt(length)*tinv(1-a/2,length-1),mu+sig/sqrt(length)*tinv(1-a/2,length-1)];
%%使用fitdist来获取置信区间
for i = 1:width
    pd(i,1) = fitdist(data(:,i),'normal');
end
f1 = figure(1);
f1.Name = 'inter_esti:标准正态分布-数据对比';
normplot(data);

f2 = figure(2);
f2.Name='inter_esti:正态分布拟合';
tiledlayout(width,1);
for i = 1:width
nexttile;
x_values = 50:1:250;
y = pdf(pd(i),x_values);
title('第i组数据');
plot(x_values,y,'LineWidth',2);
end






end